package com.huawei.appmarket.service.substance;

import android.animation.Animator;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import o.azb;
import o.cil;
import o.cim.a;
import o.cjk;
import o.cjm;
import o.cjo;
import o.Logger;
import o.dof;
import o.epv;
import o.eqx;
import o.evb;
import o.evx;
import o.ewm.c;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;
import o.kk;

public class FlowCardView extends BlurFlowBackground {
    private DownloadButton ʻ;
    private ImageView ʼ;
    private TextView ʽ;
    private TextView ˊ;
    private boolean ˊॱ = false;
    private TextView ˋ;
    private CardBean ˋॱ;
    private ImageView ˎ;
    private DownloadButton ˏ;
    private ViewGroup ˏॱ;
    private Context ͺ;
    private LinearLayout ॱ;
    private evx ॱˊ = new evx(this) {
        final /* synthetic */ FlowCardView ˏ;

        {
            this.ˏ = r1;
        }

        public void ˋ(View view) {
            BaseDistCardBean baseDistCardBean = null;
            if (this.ˏ.ˋॱ instanceof BaseDistCardBean) {
                baseDistCardBean = (BaseDistCardBean) this.ˏ.ˋॱ;
            }
            if (baseDistCardBean == null) {
                return;
            }
            if ((baseDistCardBean.ॱॱ() != null || baseDistCardBean.ˑ() != null) && baseDistCardBean.ॱॱ() != null) {
                cil.ˋ(this.ˏ.ͺ, new a().ˊ(baseDistCardBean.ॱॱ()).ˋ());
                cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                appDetailActivityProtocol.ˏ(new Request(baseDistCardBean.ॱॱ(), baseDistCardBean.u_()));
                cjk.ˎ().ˋ(this.ˏ.ͺ, new cjm("appdetail.activity", appDetailActivityProtocol));
            }
        }
    };
    private ViewGroup ॱॱ;
    private TextView ᐝ;

    public FlowCardView(Context context) {
        super(context);
        this.ͺ = context;
        ʻ();
    }

    public FlowCardView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ͺ = context;
        ʻ();
    }

    public FlowCardView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ͺ = context;
        ʻ();
    }

    private void ʻ() {
        this.ॱॱ = (ViewGroup) LayoutInflater.from(this.ͺ).inflate(h.יॱ, this);
        azb.ˏ(this.ॱॱ);
        this.ˏ = (DownloadButton) this.ॱॱ.findViewById(j.ˌˑ);
        this.ˊ = (TextView) this.ॱॱ.findViewById(j.ˌꜟ);
        this.ˋ = (TextView) this.ॱॱ.findViewById(j.ˌᐧ);
        this.ॱ = (LinearLayout) this.ॱॱ.findViewById(j.ʼᐨ);
        this.ˎ = (ImageView) this.ॱॱ.findViewById(j.ˌˌ);
    }

    public View ॱ() {
        this.ˏॱ = (ViewGroup) LayoutInflater.from(this.ͺ).inflate(h.ՙॱ, null);
        this.ʻ = (DownloadButton) this.ˏॱ.findViewById(j.ˌˑ);
        this.ʽ = (TextView) this.ˏॱ.findViewById(j.ˌꜟ);
        this.ᐝ = (TextView) this.ˏॱ.findViewById(j.ˌᐧ);
        this.ʼ = (ImageView) this.ˏॱ.findViewById(j.ˌˌ);
        return this.ˏॱ;
    }

    public boolean ˋ(CardBean cardBean) {
        this.ˋॱ = cardBean;
        if (!(cardBean instanceof BaseDistCardBean)) {
            return false;
        }
        if (ˋ((BaseDistCardBean) cardBean)) {
            ॱ((BaseDistCardBean) cardBean);
            setFlowCardShow(((BaseDistCardBean) cardBean).ॱʽ());
            return true;
        }
        ᐝ();
        return false;
    }

    public CardBean ˏ() {
        return this.ˋॱ;
    }

    private void ᐝ() {
        if (this.ॱॱ != null && this.ˏॱ != null) {
            this.ॱॱ.removeAllViews();
            this.ॱॱ.setVisibility(8);
            this.ˏॱ.removeAllViews();
            this.ˏॱ.setVisibility(8);
        }
    }

    private boolean ˋ(BaseDistCardBean baseDistCardBean) {
        return !dof.ॱ(baseDistCardBean.ͺˏ());
    }

    public boolean ˊ() {
        return this.ˊॱ;
    }

    public void setFlowCardShow(boolean z) {
        this.ˊॱ = z;
    }

    private void ॱ(BaseDistCardBean baseDistCardBean) {
        this.ˊ.setText(baseDistCardBean.v_());
        this.ˋ.setText(baseDistCardBean.ˏˏ());
        eqx.ˏ(this.ˎ, baseDistCardBean.ॱˌ(), "app_default_icon");
        this.ˎ.setOnClickListener(this.ॱˊ);
        this.ॱ.setOnClickListener(this.ॱˊ);
        this.ˏ.setParam(baseDistCardBean);
        this.ˏ.ॱ();
        this.ʽ.setText(baseDistCardBean.v_());
        this.ᐝ.setText(baseDistCardBean.ˏˏ());
        eqx.ˎ(this.ʼ, baseDistCardBean.ॱˌ());
        this.ʼ.setOnClickListener(this.ॱˊ);
        this.ʻ.setParam(baseDistCardBean);
        this.ʻ.ॱ();
        if (baseDistCardBean.ٴ() != 0) {
            this.ˋ.setText(baseDistCardBean.ߴ());
            this.ᐝ.setText(baseDistCardBean.ߴ());
        }
    }

    public void ˋ() {
        this.ˏ.ॱ();
        this.ʻ.ॱ();
    }

    public void ˎ() {
        try {
            Bitmap createBitmap = Bitmap.createBitmap(epv.ˎ(this.ͺ), this.ͺ.getResources().getDimensionPixelSize(d.ˋˊ), Config.ARGB_8888);
            createBitmap.eraseColor(this.ͺ.getResources().getColor(c.ॱˎ));
            setBackground(new BitmapDrawable(this.ͺ.getResources(), evb.ˏ(createBitmap, 125, 15)));
            setAlpha(0.98f);
        } catch (Exception e) {
            Logger.e("flowcardview:", e.toString());
        }
    }

    public void setFlowLayoutAnimation(FrameLayout frameLayout) {
        if (frameLayout == null) {
            Logger.e("FlowCardView", "flowCardLayout is null");
            return;
        }
        Animator ofFloat = ObjectAnimator.ofFloat(null, "translationY", new float[]{(float) getResources().getDimensionPixelSize(d.ᐝ), 0.0f});
        ofFloat.setDuration(250);
        ofFloat.setInterpolator(new kk());
        Animator ofFloat2 = ObjectAnimator.ofFloat(null, "translationY", new float[]{0.0f, (float) getResources().getDimensionPixelSize(d.ᐝ)});
        ofFloat2.setDuration(250);
        ofFloat2.setInterpolator(new kk());
        LayoutTransition layoutTransition = new LayoutTransition();
        layoutTransition.setAnimator(2, ofFloat);
        layoutTransition.setAnimator(3, ofFloat2);
        frameLayout.setLayoutTransition(layoutTransition);
    }
}
